/**
 * Created by IntelliJ IDEA.
 * User: Bezdelnick
 * Date: 18.05.13
 * Time: 1:29
 * To change this template use File | Settings | File Templates.
 */
package {
import flash.geom.Point;

public class MaterialPoint extends PhysicsObject {
    private var _velocity:Point;
    private var _moveAngle:Number;
    private var _speed:Number;

    private var _startPosition:Point;
    private var _startSpeed:Number;
    private var _startMoveAngle:Number;

    public function MaterialPoint() {
        draw();
        velocity = new Point(0, 0);
        moveAngle = 0;
        speed = 0;

        //startPosition = new Point(x, y);
        startSpeed = 0;
    }

    override public function draw():void {
        graphics.clear();
        graphics.beginFill(0xff0000);
        graphics.drawCircle(0, 0, 8);
        graphics.endFill();

        graphics.lineStyle(1, 0x0000ff);
        graphics.moveTo(0, 0);
        graphics.lineTo(
                5 * speed * Math.cos(moveAngle / 180 * Math.PI),
                -5 * speed * Math.sin(moveAngle / 180 * Math.PI));
    }

    /*public function applyStartPosition():void {
        x = _startPosition.x;
        y = _startPosition.y * -1;
        position = new Point(x, y);
    }*/

    public function get velocity():Point {
        return _velocity;
    }

    public function set velocity(value:Point):void {
        _velocity = value;
        //_speed = 0;
        //
    }

    public function get moveAngle():Number {
        return _moveAngle;
    }

    public function set moveAngle(value:Number):void {
        _moveAngle = value;
        draw();
    }

    public function get speed():Number {
        return _speed;
    }

    public function set speed(value:Number):void {
        _speed = value;
        draw();
    }

    public function get startPosition():Point {
        return new Point(_startPosition.x, -1 * _startPosition.y);
    }

    public function set startPosition(value:Point):void {
        value.y *= -1;
        _startPosition = value;
    }

    public function get position():Point {
        return new Point(x, -1 * y);
    }

    public function set position(value:Point):void {
        x = value.x;
        y = (-1) * value.y;
    }

    public function get startSpeed():Number {
        return _startSpeed;
    }

    public function set startSpeed(value:Number):void {
        _startSpeed = value;
    }


    public function get startMoveAngle():Number {
        return _startMoveAngle;
    }

    public function set startMoveAngle(value:Number):void {
        _startMoveAngle = value;
    }
}
}
